<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 200px;
    }
</style>
<form class="layui-form seller-form" action="" method="post">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">User Name：</label>
            <div class="layui-input-inline">
                <input type="text" name="user_name" lay-verify="title" style="width:200px;" value=""
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Card Num：</label>
            <div class="layui-input-inline">
                <input type="text" name="card_num" lay-verify="title" style="width:200px;" value=""
                     class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Child User Token：</label>
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="user_token" lay-verify="title" style="width:250px;"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="padding-left: 100px;">
            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="user-search">
                <i class="iconfont icon-chaxun"></i>Search</button>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="userTable" lay-filter="test"></table>
</div>

<script>
    layui.use(['form', 'table'], function () {
        var tableIn = layui.table.render({
            elem: '#userTable',
            height: 'full-139',
            cellMinWidth: '80',
            totalRow: true,
            page: 'true',
            limit: '20',
            toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
            url: "{:url('user/childUser')}?_ajax=1",
            id: 'userTable',
            defaultToolbar: ['filter', 'exports'],
            cols: [[
                { type: 'numbers'},
                { field: 'username', align: 'center', title: 'User Name' },
                { field: 'child_name', align: 'center', title: 'Child Name' , width: 200,
                    templet: function (d) {
                        return d.first_name + ' ' + d.last_name;
                    }
                },
                { field: 'card_num', title: 'Card Num',width: 120,
                    templet:function (d) {
                        var num = d.card_num;
                        if(num){
                            return " **** " + num.substr(-4);
                        }else{
                            return "--";
                        }
                    },align:"left"},
                { field: 'user_token', align: 'left',  title: 'User Token'},
                { field: 'account_balance', title: 'Account Balance($)', align:"right",width:160,
                    style:'color:#FF5722;font-weight:bold', totalRow: true},
                { field: 'balance', title: 'Available Balance($)', align:"right",width:160,
                    style:'color:#FF5722;font-weight:bold', totalRow: true},
                { field: 'child_num', title: 'Child Name', width:150},
                { field: 'ctime', align: 'center', title: 'Create Time',width:180,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                }
            ]]
        });
        //搜索
        layui.form.on('submit(user-search)', function (data) {
            layui.table.reload('userTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                },
                method:'POST'
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>